package com.gzhryc.socket;

import com.gzhryc.socket.mosquitto.MosquittoThreadPoolMqttClient;
import com.gzhryc.socket.mosquitto.MosquittoThreadPoolMqttServer;
import com.gzhryc.socket.netty.NettyThreadPoolTCPClient;
import com.gzhryc.socket.netty.NettyThreadPoolTCPServer;

public class SocketNodeFactory {

	public static SocketNode getServer(SocketConfig config,SocketCallback callback) {
		if(SocketConstants.CONFIG_TYPE_MQTT.equals(config.getType())) {
			return new MosquittoThreadPoolMqttServer(config,callback);
		}else if(SocketConstants.CONFIG_TYPE_NORMAL.equals(config.getType())){
			return new NettyThreadPoolTCPServer(config,callback);
		}
		return null;
	}
	
	public static SocketNode getClient(SocketConfig config,SocketCallback callback) {
		if(SocketConstants.CONFIG_TYPE_MQTT.equals(config.getType())) {
			return new MosquittoThreadPoolMqttClient(config,callback);
		}else if(SocketConstants.CONFIG_TYPE_NORMAL.equals(config.getType())){
			return new NettyThreadPoolTCPClient(config,callback);
		}
		return null;
	}
}
